package com.liukai.todo.entity;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;

/**
 * 公共返回对象
 *
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@ToString
@Accessors(chain = true)
@ApiModel(value="RespBean对象", description="存放RespBean")
public class RespBean {

    @ApiModelProperty(value = "状态码")
    private long code;
    @ApiModelProperty(value = "返回的信息")
    private String msg;
    @ApiModelProperty(value = "返回的数据")
    private Object obj;

    /**
     * 成功返回结果
     * @param msg
     * @param obj
     * @return
     */
    public static  RespBean success(String msg, Object obj) {
        return new RespBean(200,msg,obj);
    }

    /**
     * 成功返回结果
     * @param msg
     * @return
     */
    public static RespBean success(String msg) {
        return new RespBean(200,msg,null);
    }

    /**
     * 失败返回结果
     * @param msg
     * @return
     */
    public static RespBean error(String msg) {
        return new RespBean(500,msg,null);
    }

    /**
     * 失败返回结果
     * @param msg
     * @param obj
     * @return
     */
    public static RespBean error(String msg, Object obj) {
        return new RespBean(500,msg,obj);
    }

}
